﻿using Newtonsoft.Json.Linq;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication3
{
	public class RestFul
	{
        RestClient client = new RestClient("http://192.168.2.99:9000");
        public JObject sendRequest(string url, Method RequestType, string field, string param)
        {
            var request = new RestRequest(url, RequestType);
            // request.AddQueryParameter(field,param);
            if (field != null)
            {
                request.AddUrlSegment(field, param);
            }


            try
            {
                RestResponse response = client.Execute(request);
                //   client. = new[] { "application/json", "text/json", "text/x-json", "text/javascript", "text/plain", "*/*" };
                var content = response.Content;

                JObject jobj = JObject.Parse(content);
                return jobj;
                //解析hobbys


            }
            catch
            {
            //    MessageBox.Show("账号不存在或者服务端未启动");
                return null;
                //throw;
            }

        }





        //public List<ADMIN_UNITDTO> sendRequestList(string url, Method RequestType, string field, string param)
        //{
        //    var client = new RestClient(Constant.URL);
        //    var request = new RestRequest(url, RequestType);
        //    //     RestResponse<Response<myModel>>    
        //    IRestResponse<List<ADMIN_UNITDTO>> response = client.Execute<List<ADMIN_UNITDTO>>(request);
        //    List<ADMIN_UNITDTO> result = response.Data;
        //    return result;

        //}
    }
}